﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="UserPanel.aspx.cs" Inherits="LotteryVote.UserPanel" %>

<%@ Register Src="~/Controls/UserSearchBar.ascx" TagPrefix="LV" TagName="UserSearch" %>
<asp:Content ID="Header" ContentPlaceHolderID="head" runat="server">
    <link href="Style/TableBaseStyle.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Main" ContentPlaceHolderID="main" runat="server">
    <LV:UserSearch ID="lv_userSerach" runat="server" />
    <input type="button" value='<%=GetGlobalResourceObject("Resource","New")+GetAgentType() %>'
        onclick="buildAddFrame()" />
    <asp:Repeater ID="rpt_user" runat="server" OnItemCommand="rpt_user_ItemCommand">
        <HeaderTemplate>
            <table cellpadding="0" cellspacing="0">
                <thead>
                    <tr>
                        <td>
                            <%=GetGlobalResourceObject("Resource", "No")%>
                        </td>
                        <td>
                            <%=GetGlobalResourceObject("Resource","Name") %>
                        </td>
                        <td>
                            <%=GetGlobalResourceObject("Resource","UserName") %>
                        </td>
                        <td>
                            <%=GetGlobalResourceObject("Resource","Currency") %>
                        </td>
                        <td>
                            <%=GetGlobalResourceObject("Resource","GivenCredit") %>
                        </td>
                        <td>
                            <%=GetGlobalResourceObject("Resource", "AvailableGivenCredit")%>
                        </td>
                        <%if (CurrentUser.Role < LotteryVote.Entity.SystemRole.Agent)
                          { %>
                        <td>
                            <%=GetGlobalResourceObject("Resource", "ShareRate")%>
                        </td>
                        <%} %>
                        <td>
                            <%=GetGlobalResourceObject("Resource", "LastLoginTime")%>
                        </td>
                        <td>
                            <%=GetGlobalResourceObject("Resource", "CreateTime")%>
                        </td>
                        <td>
                            <%=GetGlobalResourceObject("Resource", "Status")%>
                        </td>
                        <td>
                            <%=GetGlobalResourceObject("Resource", "Function")%>
                        </td>
                    </tr>
                </thead>
                <tbody>
        </HeaderTemplate>
        <ItemTemplate>
            <tr>
                <td>
                    <%# Container.ItemIndex+1 %>
                </td>
                <td>
                    <%#Eval("UserInfo.Name")%>
                </td>
                <td>
                    <%#Eval("UserName") %>
                </td>
                <td>
                    VND
                </td>
                <td>
                    <%#Eval("UserInfo.GivenCredit")%>
                </td>
                <td>
                    <%#Eval("UserInfo.AvailableGivenCredit")%>
                </td>
                <%if (CurrentUser.Role < LotteryVote.Entity.SystemRole.Agent)
                  { %>
                <td>
                    <%# Convert.ToDouble(Eval("UserInfo.ShareRate"))*100 %>%
                </td>
                <%} %>
                <td>
                    <%#Eval("LastLoginTime") %>
                </td>
                <td>
                    <%#Eval("UserInfo.CreateTime") %>
                </td>
                <td>
                    <%#GetGlobalResourceObject("Resource", Eval("UserInfo.State").ToString())%>
                </td>
                <td>
                    <a class="edit" user='<%#Eval("UserId") %>' href="javascript:void">
                        <%=GetGlobalResourceObject("Resource","Edit") %></a> <a class="comm" user='<%#Eval("UserId") %>'
                            href="javascript:void">
                            <%=GetGlobalResourceObject("Resource","Commission") %></a> <a class="limit" user='<%#Eval("UserId") %>'
                                href="javascript:void">
                                <%=GetGlobalResourceObject("Resource","Limit") %></a> <a href='LoginLog.aspx?UserId=<%#Eval("UserId") %>'>
                                    <%=GetGlobalResourceObject("Resource","Log") %></a> <a href="javascript:void" user='<%#Eval("UserId") %>'
                                        class="updatePwd">
                                        <%=GetGlobalResourceObject("Resource","Password") %></a>
                    <asp:LinkButton ID="lbtn_remove" runat="server" Text="<%$Resources:Resource,Delete %>" CommandName="Delete" CommandArgument='<%#Eval("UserId") %>'
                        OnClientClick="return confirm('Are you sure?')"></asp:LinkButton>
                </td>
            </tr>
        </ItemTemplate>
        <FooterTemplate>
            </tbody> </table></FooterTemplate>
    </asp:Repeater>
    <script type="text/javascript">
        $(document).ready(function () {
            $(".edit").bind("click", function () {
                buildEditFrame($(this).attr("user"));
            });
            $(".comm").bind("click", function () {
                buildCommFrame($(this).attr("user"));
            });
            $(".limit").bind("click", function () {
                buildLimitFame($(this).attr("user"));
            });
            $(".updatePwd").bind("click", function () {
                buildFrame("UpdatePwd", 230, 350, "UpdateUserPassword.aspx?UserId=" + $(this).attr("user"));
            });
        });
        var buildAddFrame = function () {
            var div = $("<div></div>");
            var iframe = $("<iframe id=\"NewFrame\" Width=\"960\" height=\"450\" frameborder=\"0\" src=\"AddUser.aspx\" </iframe>").appendTo(div);
            div.appendTo($(document));
            var height = $("#frame").attr("height");
            div.dialog({ modal: true, minWidth: 990, minHeight: height });
        }
        var buildEditFrame = function (userId) {
            var div = $("<div></div>");
            var iframe = $("<iframe id=\"EditFrame\" Width=\"960\" height=\"450\" frameborder=\"0\" src=\"EditUser.aspx?UserId=" + userId + "\" </iframe>").appendTo(div);
            div.appendTo($(document));
            var height = $("#frame").attr("height");
            div.dialog({ modal: true, minWidth: 990, minHeight: height });
        }
        var buildCommFrame = function (userId) {
            var div = $("<div></div>");
            var iframe = $("<iframe id=\"EditFrame\" Width=\"960\" height=\"600px\" frameborder=\"0\" src=\"EditUserCommission.aspx?UserId=" + userId + "\" </iframe>").appendTo(div);
            div.appendTo($(document));
            var height = $("#frame").attr("height");
            div.dialog({ modal: true, minWidth: 990, minHeight: height });
        }
        var buildLimitFame = function (userId) {
            buildFrame("limitFrame", 600, 1020, "LimitManager.aspx?UserId=" + userId);
        }

    </script>
</asp:Content>
